package com.lhx.arrray.bilibili;

public class array_20 {
    public static boolean chang(int[] nums) {
        int money5 = 0;
        int money10 = 0;
        for(int i=0; i<nums.length; i++) {
            if(nums[i] == 5) {
                money5++;
            } else if(nums[i] == 10) {
                money5--;
                money10++;
                if(money5<0) return false;
            } else {
                money10--;
                money5--;
                if(money5<0 || money10<0) {
                    return false;
                }
            }
        }
        return true;
    }

    public static void main(String[] args) {
        int[] nums = new int[]{5,10,5,20};
        System.out.println(chang(nums));
    }
}
